﻿/*
 *Copyright(C) 2024 by CometGamming All rights reserved.
 *Unity版本：2022.3.43f1c1 
 *作者:程一峰  
 *创建日期: 2024-10-23 
 *模块说明：简易状态机
 *版本: 0.1.0
*/

using Sirenix.OdinInspector;
using UnityEngine;
using Warfare.FSM;

namespace GameAIStudy
{
    /// <summary>
    /// 目标选择
    /// </summary>
    public class FSMNodeAction_SelectTarget : FSMNodeAction
    {
        public override string ActionName => "目标选择";

        [LabelText("随机范围")]
        public float RandomRange = 10;

        public override void OnEnter(I_FSMContext context, I_FSMActor actor)
        {
            base.OnEnter(context, actor);
            Context = context as SamplePlayerContext;
            Actor = actor as SamplePlayer;
        }

        private SamplePlayerContext Context;
        private SamplePlayer Actor;

        public override E_MachineState Update(float deltaTime)
        {
            Vector3 cPos = Actor.transform.position;
            var rPos = Random.insideUnitCircle * Random.Range(1, RandomRange);
            Context.Target = cPos + new Vector3(rPos.x, 0, rPos.y);
            return E_MachineState.Sucess;
        }
    }
}
